<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    const str = "abcdef abcxyz";
    const result = str.match(/abc(?!def)/g);
    console.log(result); // ['abc']

    const result2 = /abc(?!def)/g.exec(str);
    console.log(result2); // ['abc']

  </script>
</body>

</html>